<template>
  <div>
    <el-form :inline="true" v-model="parkingform" class="demo-form-inline">
      <el-form-item label="车位信息">
        <el-select v-model="parkingform.spacenumber" placeholder="车位信息">
          <el-option
              v-for="item in parking"
              :label="item.ownerId"
              :value="item.id"
              :key="item.ownerId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="车位更新">
        <el-input v-model="parkingform.ownerId" placeholder="车位更新" @blur="checkunit()"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="checkparkingstate">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      subform: {
        spacenumber:'',
        ownerId:''
      },
      parkingform:[],
      parking:[],
      value:'',
    }
  },
  created(){
    this.findlocation();
  },
  methods: {
    // onSubmit() {
    //     this.$axios.post("manage/unit/checkunit",this.subform).then(res=>{
    //         if(res.data.unit==null){
    //             this.$message.success("添加成功");
    //         }
    //     })
    //
    // },
    findlocation(){
      this.$axios.get("manage/findlocation").then(res=>{
        this.building = res.data.parkingList;
      });
    },
    checkparkingstate(){
      this.$axios.post("manage/unit/checkparkinngstate",this.parkingform).then(res=>{
        if(res.data.parking!=null){
          this.$message.error("此车位已被占用")
        }
        else {
          this.$message.success("添加成功");
          this.parkinngform={};
        }

      })
    }
  }
}
</script>

<style scoped>

</style>